<?php

/**
 * 杂志订阅后台管理
 * @copyright (c) 2013, Alvin
 * 
 */
class MookFeedAction extends AdminAction {

    public function _initialize() {
        parent::_initialize();
    }

    public function edit() {
        if (IS_POST) {
            if(!$_POST['title'] || !$_POST['lists']){
                $this->error('参数填写不完整');
            }
            //图片上传
            $savePath                = "/Public/Uploads/" . date("Ymd") . "/";
            $file                    = $this->upload($savePath);
            if( $file['pic_url']['savename'] == false){
                $this->error('缺少杂图片志封面');
            }
            $_POST['pic_url'] = $savePath . $file['pic_url']['savename'];
            $res                     = M('Mook')->add($_POST);
            if ($res) {
                $this->success('操作成功');
            } else {
                $this->success('操作失败');
            }
        } else {
            $id = (int) $this->_get("id");
            $data = M('Mook')->find($id);
            $this->assign('data', $data);
            $this->display();
        }
    }



}

?>
